package com.xxxx.controller;

import com.xxxx.model.Department;
import com.xxxx.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class DepartmentController {
    @Autowired
    @Qualifier("departmentMapperImp")
    private DepartmentService departmentService;
    @RequestMapping("/queryall")
    public String list(Model model){
        List<Department> list =departmentService.queryAllpart();
        System.out.println(list);
        model.addAttribute("list",list);
        return "admin1";
    }
    @RequestMapping("/toAddpart")
    private String toAddpart(){
        return "toAddpart";
    }
    @RequestMapping("/addpart")
    private String addpart(Department department,Model model){
        departmentService.addpart(department);
        return "redirect:/queryall";
    }
    @RequestMapping("Deletepart")
    private String Deletepart(int code,Model model){
        System.out.println(code);
       departmentService.deletepart(code);
        return "redirect:/queryall";
    }
}
